package calorie.com.calorie.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.lxh.baselibray.BaseApplication;
import com.lxh.baselibray.base.XActivity;
import com.lxh.baselibray.util.SPUtils;

import butterknife.OnClick;
import calorie.com.calorie.R;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.util.StaticValue;


/**
 * 帐户管理
 */
public class ManagerAccountActivity extends XActivity {
    @Override
    public void initData(Bundle savedInstanceState) {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_manager_account;
    }


    @OnClick({R.id.tv_modify_login_pwd, R.id.tv_modify_deal_pwd,R.id.btn_login_out,R.id.tv_modify_phone})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_modify_login_pwd:
                startActivity(new Intent(context,ModifyLoginPwdActivity.class));
                break;
            case R.id.tv_modify_deal_pwd:
                startActivity(new Intent(context,ModifyDealPwdActivity.class));
                break;
            case R.id.btn_login_out:
                clearData();
                BaseApplication.getActivityManage().finishAll();
                startActivity(new Intent(context,LoginActivity.class));
                break;
            case R.id.tv_modify_phone://修改手机号码
                startActivity(new Intent(context,ActivityModifyPhone.class));
                break;
        }
    }

    private void clearData() {
        SPUtils.putInt(Constant.USER_ID,-1,context);
        SPUtils.putString(Constant.PHONE,null,context);
        SPUtils.putString(Constant.INVITE_CODE,null,context);
        SPUtils.putString(Constant.LOGIN_PWD,null,context);
        SPUtils.getString(Constant.NICK_NAME,null,context);
        SPUtils.getString(Constant.ACCOUNT,null,context);
        SPUtils.getString(Constant.RECEIVE_ADDRESS,null,context);
        SPUtils.getString(Constant.PURSE_ADDRESS,null,context);
        SPUtils.getString(Constant.LOGIN_TIME,null,context);
        StaticValue.user=null;
        StaticValue.userAssets=null;
    }
}
